<?php
require_once("../includes/config.php");
include DIR_INCLUDES_FT.'bootstrap.php';

switch ($_POST['accao']){
	case 'verifica_codigo':
		$id = (isset($_POST['id']))?$_POST['id']:"";
		
		$query = new Doctrine_Query();
		$num_repetidos = $query->from("CodigosBarras c")->where("c.codigo_barras = ? and id != ?",array($_POST['codigo_barras'], $id))->count();
		
		if($num_repetidos > 0){
			echo json_encode(false);
		} else {
			echo json_encode(true);
		}
	break;
}

?>